<template>
    <!-- 组件的模板 -->
    <div class="page resume" v-if="center">
        <div class="mod-user com-border-top com-border-bottom">
            <img class="avatar" @click.stop="bigPicture" v-if="logo_thumb_url" :src="logo_thumb_url" alt="">
            <img class="avatar" v-else src="http://sta.doumistatic.com/src/image/saas/avatar.png" alt=""> 
            <p class="name">{{vcs.personal_info.name}}
                <span class="bg_sprite gender female" v-if="vcs.personal_info.gender == '女'"></span>
                <span class="bg_sprite gender male" v-else></span>
            </p>
            <span class="bg_sprite phone" @click="call(vcs.personal_info.mobile)"></span>
        </div>
        <div class="weui-cells__title">个人信息</div>
        <div class="weui-cells">
            <div class="weui-cell" v-if="vcs.personal_info.age">
                <div class="weui-cell__bd">
                    <p><span class="title">年龄</span>{{vcs.personal_info.age}}</p>
                </div>                
            </div>
            <div class="weui-cell" v-if="vcs.personal_info.at_school">
                <div class="weui-cell__bd">
                    <p><span class="title">身份</span>{{vcs.personal_info.at_school}}</p>
                </div>                
            </div>
            <div class="weui-cell" v-if="vcs.personal_info.height">
                <div class="weui-cell__bd">
                    <p><span class="title">身高</span>{{vcs.personal_info.height}}</p>
                </div>                
            </div>
            <div class="weui-cell" v-if="vcs.personal_info.weight">
                <div class="weui-cell__bd">
                    <p><span class="title">体重</span>{{vcs.personal_info.weight}}</p>
                </div>                
            </div>
            <div class="weui-cell" v-if="vcs.personal_info.health_cert">
                <div class="weui-cell__bd">
                    <p><span class="title">健康证</span>{{vcs.personal_info.health_cert}}</p>
                </div>                
            </div>
            <div class="weui-cell" v-if="vcs.personal_info.province_str != '' || vcs.personal_info.city_str != '' || vcs.personal_info.district_str != ''">
                <div class="weui-cell__bd">
                    <p> <span class="title">居住地址</span>
                        <span v-if="vcs.personal_info.province_str == vcs.personal_info.city_str">{{vcs.personal_info.province_str}} {{vcs.personal_info.district_str}}</span>
                        <span v-else>{{vcs.personal_info.province_str}} {{vcs.personal_info.city_str}} {{vcs.personal_info.district_str}}</span>
                    </p>
                </div>                
            </div>                 
        </div>
        <div v-if="vcs.education_backgroud.school_name != '' || vcs.education_backgroud.degree != '' || vcs.education_backgroud.enrol_date != ''">
            <div class="weui-cells__title">教育经历</div>
            <div class="weui-cells">
                <div class="weui-cell" v-if="vcs.education_backgroud.school_name">
                    <div class="weui-cell__bd">
                        <p><span class="title">学校</span>{{vcs.education_backgroud.school_name}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.education_backgroud.degree">
                    <div class="weui-cell__bd">
                        <p><span class="title">学历</span>{{vcs.education_backgroud.degree}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.education_backgroud.enrol_date">
                    <div class="weui-cell__bd">
                        <p><span class="title">入学年份</span>{{vcs.education_backgroud.enrol_date}}</p>
                    </div>                
                </div>
            </div>
        </div>
        

        <div v-if="vcs.third_party_accout.weixin !='' || vcs.third_party_accout.qq != ''">
            <div class="weui-cells__title">其他联系方式</div>
            <div class="weui-cells">
                <div class="weui-cell" v-if="vcs.third_party_accout.weixin">
                    <div class="weui-cell__bd">
                        <p><span class="title">微信号</span>{{vcs.third_party_accout.weixin}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.third_party_accout.qq">
                    <div class="weui-cell__bd">
                        <p><span class="title">QQ</span>{{vcs.third_party_accout.qq}}</p>
                    </div>                
                </div>
            </div>
        </div>
        
        <div v-if="vcs.work_experience.length">
            <div class="weui-cells__title">工作经历</div>
            <ul class="timeline">
                <li v-for="work in vcs.work_experience">
                    <span class="dot"></span>
                    <span class="time">{{work.work_time}}</span>
                    <p class="work">{{work.post_title}}</p>
                </li>
            </ul>
        </div>
    </div>  

    <div class="page" v-if="empty">
        <div class="mod-empty">
            <div class="icon icon_1"></div>
            <p class="tip">该成员暂无简历信息</p>
        </div>
    </div> 
        
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import clientUi from 'gapi/clientUi.js'
    import widget from 'gapi/widget.js'
    import * as util from 'js/util.js'
    import commonPage from 'clientApi/commonPage.js'

    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

     let userid = ''
     let doumi_user_id = ''
    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                empty:false,
                center:false,
                vcs:{
                    personal_info:{},
                    education_backgroud:{},
                    work_experience:[],
                    third_party_accout:{}
                },
                logo_url_big:'',  //查看大图
                logo_thumb_url:''   // 原图 小图
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                userid = util.getUrddataString('userId')
                doumi_user_id =util.getUrddataString('doumiUserId')
                this.vcInit()

            },
            vcInit (){
                commonPage.loadPageStatus('loading')
                util.ajax({
                    url:'/user/profile',
                    type:'GET',
                    data:{
                        team_id:0,
                        project_id:0,
                        user_id:userid,
                        doumi_user_id:doumi_user_id
                    },
                    timeout:10000,
                    success:(obj) => {
                        console.log(JSON.stringify(obj))
                        commonPage.loadPageStatus('loadSuccess')
                        if(obj&&obj.errno == 0){
                            // this.empty = false
                            if(obj.data != ''){
                                this.empty = false
                                this.center = true
                                this.logo_url_big = obj.data.personal_info.logo_url
                                this.logo_thumb_url = obj.data.personal_info.logo_thumb_url
                                this.vcs.personal_info = obj.data.personal_info;   //个人信息
                                this.vcs.education_backgroud = obj.data.education_backgroud;  //教育经历
                                this.vcs.work_experience = obj.data.work_experience;  //工作经历
                                this.vcs.third_party_accout = obj.data.third_party_accout;  //联系方式
                            }else{
                                this.empty = true
                                this.center = false
                            }
                        }else{
                             widget.toast(obj.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            /**
             * 头像大图预览
             */
            bigPicture (){
                let that = this;
                let title = '个人头像';
                let imgArr = [];
                let subUrl = this.logo_url_big;
                imgArr.push(subUrl); 
                let index = imgArr.length-1;
                clientUi.bigPicturePreview(title, imgArr, index)
            },
            /*拨打电话*/
            call (mobile){
                const title = '拨打电话';
                const message = mobile;
                const okBtn = '确定';
                const cancelBtn = '取消';
                const imageName = 'meiyou';
                clientUi.showPhoneDialog(title, message, okBtn, cancelBtn, imageName, () => {
                    
                })
            }
        },
        created(){

            this.init();
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/talent-pool.css"></style>



